📚 SAP Business One SDK Help

Add items sample
See Also

Description

The following example shows how to add an Items object to SAP Business One database.
Sub Add_Item()
    Dim RetVal As Long
    Dim ErrCode As Long
    Dim ErrMsg As String
    Dim vItem As SAPbobsCOM.Items

    Set vItem = vCmp.GetBusinessObject(oItems)
    'Set value to mandatory fields:
    vItem.ItemCode = "MyNewItem"
    'Set Value to other fields
    vItem.ItemName = "MyNewItem Name"
    vItem.WhsInfo.WarehouseCode = "01"
    'Adding the Item
    RetVal = vItem.Add
    'Checking the result
    If RetVal <> 0 Then
        vCmp.GetLastError ErrCode, ErrMsg
        MsgBox ErrCode & " " & ErrMsg
    End If
 End Sub